export default class Stack {
  #stack = [];
  // 返回最后一个元素
  peek() {
    return this.isEmpty() ? null : this.#stack[this.#stack.length - 1];
  }
  push(val) {
    this.#stack.push(val);
  }

  pop() {
    return this.#stack.pop();
  }

  size() {
    return this.#stack.length;
  }

  isEmpty() {
    return this.size() <= 0;
  }
}
